package com.guoxin.concurrentprogramming.chapter4.future.jdk;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;

public class Main {

    public static void main(String[] args) throws InterruptedException, ExecutionException {
        RealData realData = new RealData("name");

        FutureTask<String> task = new FutureTask<>(realData);

        ExecutorService service = Executors.newSingleThreadExecutor();

        service.submit(task);

        System.out.println("执行完毕");

//        Thread.sleep(2000);

        System.out.println("数据："+task.get());
    }
}
